
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <base href="${pageContext.servletContext.contextPath}/">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="static/js/layui/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="static/css/layui/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>报销单基本信息</legend>
        </fieldset>

        <form class="layui-form" action="">

            <div class="layui-form-item">

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">报销日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="date" id="date" lay-verify="date" placeholder="年/月/日" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>



                <div class="layui-inline">
                    <label class="layui-form-label">经办人</label>
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="manager">
                            <option value="" selected>请选择经办人</option>
                            <option value="1">赵六</option>
                            <option value="2">王武</option>
                            <option value="3">孙策</option>
                            <option value="4">小乔</option>
                            <option value="5">刘文凯</option>
                        </select>
                        <div style="position: relative;right: 45px"><input type="checkbox" name="like1[read]" lay-skin="primary" ><span>以短信的方式通知经办人</span></div>
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="contact">
                            <option value="" selected>请选择联系人</option>
                            <option value="1">赵六</option>
                            <option value="2">王武</option>
                            <option value="3">孙策</option>
                            <option value="4">小乔</option>
                            <option value="5">刘文凯</option>
                        </select>
                        <div style="position: relative;right: 45px"><input type="checkbox" name="like1[read]" lay-skin="primary" ><span>以短信的方式通知经办人</span></div>
                    </div>
                </div>
            </div>





            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">事由</label>
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="reason">
                            <option value="">请选事由</option>
                            <option value="1">报销版面费</option>
                            <option value="2">报销公差费用</option>
                            <option value="3">其他费用</option>
                        </select>
                    </div>
                </div>
            </div>



            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" id="remark"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

        </form>
    </div>
</div>

<script src="static/js/layui/layui-v2.6.3/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
             , $ = layui.jquery;
        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            let id = 1;
            //获取的日期
            let date = data.field.date;
            //获取经办人的名字
            let manager = $("#manager").find("option:selected").text();
            //获取联系人的名字
            let contact = $("#contact").find("option:selected").text();
            //获取报销事由
            let reason = $("#reason").find("option:selected").text();
            //备注
            let remark = $("#remark").val();
            $.ajax({
                type:"post",
                url:"reimburse/saveReimburse",
                data:{
                    "reimburseContact":contact,
                    "reimburseReason":reason,
                    "reimburseRemark":remark,
                    "reimburseDate":date,
                    "reimburseManager":manager
                },
                dataType:"json",
                success:function (json){
                    if (json.statusCode==200){
                        var index = layer.alert(json.message, {
                            title: '保存信息'
                        }, function () {
                            // 关闭弹出层
                            layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                            //局部刷新
                            parent.layui.table.reload("munu-table",{where:{page:1}});
                        });
                    }
                }

            });
            return false;
        });
    });
</script>

</body>
</html>
